'use strict';

import React, {Component, PropTypes} from 'react';
import {List, ListItem, Col} from 'amazeui-react';

export default class Table extends Component {
	/*
	 * 构造函数。
	 *
	 * @param props 只读属性
	 */
	constructor(props) {
		super(props);
		this.state = {};
	}

	/*
	 * 渲染视图。
	 */
	render() {
		let listItems = [];
		for (let i = 0; i < this.props.children.length; i++) {
			let cols = [];

			for (let j = 0; j < this.props.column.length; j++) {
				cols.push(
					<Col
						sm={this.props.column[j]}
						className="am-text-center"
						key={j}
					>{this.props.children[i][j]}</Col>
				);
			}

			listItems.push(
				<ListItem 
					className="am-cf"
					key={i}
					style={{
						lineHeight: '40px',
						fontWeight: i === 0 ? 'bold' : 'normal'
						// backgroundColor: i === 0 ? '#f8d347' : '#ffffff'
					}}
				>{cols}</ListItem>
			);
		}

		return (
			<List
				static
				border
			>{listItems}</List>
		);
	}
}

Table.propTypes = {
	column: PropTypes.array
};
Table.defaultProps = {
	column: []
};
